<?php
include('../config.php');

// 接收前端请求发送过来的数据
$name = $_GET['name'];
$price = $_GET['price'];
$num = $_GET['num'];

// 根据数据拼接sql语句
$sql = "insert into xdapp (name,price,num) values ('$name',$price,$num)";

$res = mysql_query($sql);

if ($res) {
  echo json_encode(array(
    "code" => 200,
    "body" => array(
      "msg" => "添加成功，你真棒"
    )
  ));
} else {
  echo json_encode(array(
    "code" => 400,
    "body" => array(
      "msg" => "网络错误，再来一次"
    )
  ));
}
?>